package org.aersoft.jokebook.adapters;

import java.util.ArrayList;

import org.aersoft.jokebook.beans.ItemBean;
import org.aersoft.jokebook.fragments.ItemFragment;

import android.app.Fragment;
import android.app.FragmentManager;
import android.support.v13.app.FragmentStatePagerAdapter;

/**
 * An class to adapt a ArrayList of {@link ItemBean} for
 * the fragment layout.
 */
public class ItemFragmentAdapter extends FragmentStatePagerAdapter {

	ArrayList<ItemBean> arrayBeans;

	/**
	 * Constructor method of adapter class.
	 * @param fragmentManager of (@link FragmentManager) type.
	 * @param arrayBeans of {@link ItemBean} type.
	 */
	public ItemFragmentAdapter(FragmentManager fragmentManager, ArrayList<ItemBean> arrayBeans) {
		super(fragmentManager);
		this.arrayBeans = arrayBeans;
	}

	@Override
	public Fragment getItem(int position) {
		return ItemFragment.create(position, arrayBeans);
	}

	@Override
	public int getCount() {
		return arrayBeans.size();
	}
}
